package com.ashapo.example;

public class Example008Class {
    int id;

    public String name;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Example008Class() {
        System.out.println("无参构造");
    }

    public Example008Class(int id) {
        System.out.println("带参构造1");
        this.id = id;
    }

    public Example008Class(int id, String name) {
        System.out.println("带参构造2");
        this.id = id;
        this.name = name;
    }

    /**
     * 测试class
     * @param args
     */
    public static void main(String[] args) {
        Example008Class ex = new Example008Class();
        //属性在定义时已分配了默认值
        System.out.println("id = " + ex.id);
        System.out.println("name = " + ex.name);

        ex.id = 110;
        ex.name = "陈峰展";
        System.out.println("id = " + ex.id);
        System.out.println("name = " + ex.name);

        ex.setId(120);
        ex.setName("梁燕萍");
        System.out.println("id = " + ex.getId());
        System.out.println("name = " + ex.getName());

        //一些内置方法
        System.out.println("class = " + ex.toString());
        System.out.println("class = " + ex.getClass());

        Example008Class ex11 = new Example008Class(11);
        System.out.println("id = " + ex11.getId());
        System.out.println("name = " + ex11.getName());

        Example008Class ex22 = new Example008Class(22, "二货");
        System.out.println("id = " + ex22.getId());
        System.out.println("name = " + ex22.getName());
    }
}
